<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var str = '相思是病,你是我命'
        //根据字符查找位置
        console.log(str.indexOf('病')) // 3
        console.log(str.lastIndexOf('病')) // 3

        //根据位置查找字符
        console.log(str[3]) //病

        //charAt 返回索引对应的字符
        console.log(str.charAt(3)) //病

        // charCodeAt 返回对应索引的acall码
        console.log(str.charCodeAt(3)) //30149
    </script>
</body>
</html>